<template>
  <div>
    <div class="h60">
      <span class="exnum">{{ Num }}.{{ item.title }}</span>
      <span class="labels">
        <span v-if="item.isJt == '1'">机经</span>
        <span v-if="item.isJt !== '1'" style="background: #7cc3d6">练习题</span>
        <span
          style="background: #ff5e4e"
          v-if="item.labelStyle == 'wrong-color'"
          >错题</span
        >
        <span style="background: #13bfbf" v-if="item.isYc == '1'"
          >本周预测</span
        >
        <span style="background: #94d0f7">{{ item.titleNumber }}</span>
      </span>
    </div>

    <div class="player">
      <Audioplayer
        v-if="item.url"
        :url="item.url"
        :readyTime="readyTime"
      ></Audioplayer>
      <h1 v-if="item.url==''" class="none_audio_tip">此题暂未上传录音</h1>
    </div>

    <!-- 单项选择 -->
    <div class="radio">
      <div class="descb">{{ item.content }}</div>
      <div class="title">
        {{ subject.content }}
      </div>
      <el-form>
        <el-radio-group v-model="checkedRadio">
          <div v-for="(item, index) in radio" :key="index">
            <el-radio size="medium" :label="+index + 1" @change="getRadioVal"
              ><span ref="options">{{ item }}</span></el-radio
            >
          </div>
        </el-radio-group>
      </el-form>
    </div>
    <div class="time">
      <span v-if="readyTime > 0">答题时间：{{ s_to_hs(answerTime) }}</span>
      <span v-if="readyTime == 0">准备时间：{{ s_to_hs(readyTime) }}</span>
    </div>
  </div>
</template>

<script>
import listeningUtil from "@/utils/listeningUtil";
import Audioplayer from '../../player'
export default {
  props: ['item', 'Num'],
  mixins: [listeningUtil],
  components: {
    Audioplayer,
  },
  data () {
    return {
      answerTime: 0,
      radio: [
      ],
      checkedRadio: '',
      subject: {}
    }
  },
  created () {
    setInterval(this.countDownReady, 1000)
    // this.getData()
    this.radio = this.item.option.split('&@#')

    this.checkedRadio=this.item.answer-0
  },
  methods: {
    getRadioVal () {
      this.$emit('sendAnswer', this.checkedRadio)
    },

  },
}
</script>

<style lang="less" scoped>
.none_audio_tip{
  font-size: 1.25rem;
  color: #999;
  padding: 1.125rem;
}
.descb {
  margin-bottom: 1.125rem;
  color: #666;
  font-size: 1.125rem;
  font-weight: bold;
  padding: 0 1rem;
}
.time {
  font-size: 1rem;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #333333;
  position: relative;
  margin-top: 1.875rem;
  span {
    margin-right: 1.875rem;
  }
  .iconfont {
    font-size: 1.5rem;
    color: #ccc;
  }
  .end {
    position: absolute;
    right: -1.5rem;
    text-align: right;
  }
}
.player {
  margin-bottom: 1.25rem;
  border: 1px dashed #ff5e4e;
  background-color: #fffafa;
}
// 单选
.radio {
  background-color: #f7f7f7;
  padding: 1rem 0;
  margin-bottom: 1.25rem;
  .title {
    margin: 0 3.125rem;
    margin-bottom: 1.125rem;
    color: #666;
    font-size: 1.125rem;
  }
  .el-radio {
    margin-left: 1.125rem;
    white-space: pre-wrap;
    line-height: 2.1875rem;
  }
  /deep/.el-radio__input.is-checked .el-radio__inner {
    background-color: #ff5e4e;
    border-color: #ff5e4e;
  }
  /deep/.el-radio__input.is-checked + .el-radio__label {
    color: #666;
    width: 70rem;
  }
  /deep/.el-radio__label {
    font-size: 1.125rem;
  }
  /deep/.el-radio-group {
    width: 70rem;
  }
}
.h60 {
  margin-bottom: 1.25rem;
  height: 3.75rem;
  line-height: 3.75rem;
  padding-left: 1.25rem;
  box-sizing: border-box;
  background-color: #f7f7f7;
  display: flex;
  position: relative;
  margin-bottom: 1rem;
  .exnum {
    width: 45rem;
    font-size: 1rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .labels {
    display: flex;
    justify-content: flex-end;
    width: 21.25rem;
    span {
      height: 1.875rem;
      line-height: 1.875rem;
      padding: 0 0.375rem;
      box-sizing: border-box;
      background-color: #ff9b4f;
      border-radius: 0.1875rem;
      margin: 0.9375rem 0.46875rem;
      color: #fff;
      box-sizing: border-box;
    }
  }
}
</style>